<template>
  <div>
      <ul>
          <li v-for="(v) in list" :key="v.id">{{v.username}} <button @click="del(v.id)">删除</button> </li>
      </ul>
  </div>
</template>

<script>
import {apiusers,apideleteUsers} from "@/api"
import {ref,onMounted} from 'vue'
export default {
    setup(){
        const list = ref([])

        
        const getList = () => {
            apiusers().then(res=>{
                list.value = res
            })
        }
        const del = (id) => {
            apideleteUsers({id}).then(res => {
                alert('删除成功')
                getList()
            })
        }

        onMounted(()=>{
            getList()
        })
        return {
            list,
            del
        }
    }
}
</script>

<style>

</style>